﻿
//
// Copyright (c) 2024 BPer
//
#ifndef BPERAPP_BPerPushCapture_H_
#define BPERAPP_BPerPushCapture_H_
#include <bperutil/BPerType.h>
#include <bperaudiodev/BPerAudioCapture.h>
#include <bperutil/sys/BPerThread2.h>
#include <bpercapture/BPerMultiVideoCapture.h>
#include <bpercapture/BPerScreenCapture.h>
#include <bperutil/buffer/BPerAudioBuffer.h>
#include <bperutil/buffer/BPerVideoBuffer.h>
#include <bperavutil/audio/BPerRtcAec.h>
#include <bperutil/buffer/BPerAudioPlayBuffer.h>
class BPerPushCapture :public BPerThread {
public:
	BPerPushCapture(BPerContext *pcontext);
	virtual ~BPerPushCapture();
public:
        void startCamera();

        void stopCamera();

        void setScreenInterval(int32_t pinterval);
        void setDrawmouse(bool isDraw);
	void startVideoCaptureState();
	void startScreenCaptureState();
	void stopVideoCaptureState();
	void stopScreenCaptureState();
	int32_t initVideo();

	void startVideoCapture();
	void startScreenCapture();
	BPerVideoBuffer * getOutVideoBuffer();
	BPerVideoBuffer * getPreVideoBuffer();

	BPerVideoBuffer * getScreenOutVideoBuffer();
	BPerVideoBuffer * getScreenPreVideoBuffer();
	void stopAll();
	void change(int32_t st);



#if BPer_Enable_Vr
	void addVr();
	void delVr();
#endif
private:
	BPerAudioCapture *m_audioCapture;
	BPerMultiVideoCapture *m_videoCapture;

	BPerVideoBuffer *m_out_videoBuffer;
	BPerVideoBuffer *m_pre_videoBuffer;

	BPerVideoBuffer *m_screen_pre_videoBuffer;
	BPerVideoBuffer *m_screen_out_videoBuffer;
	BPerScreenCapture* m_screenCapture;

	BPerContext *m_context;
	BPerAudioBuffer *m_out_audioBuffer;

#if BPer_Enable_Vr
        BPerVideoBuffer *m_out_vr_pre_videoBuffer;
#endif
public:
	void stop();
	int32_t m_isStart;
protected:
	void run();
#if BPer_Enable_Vr
        void startLoop();
#else
	void startLoop(){};
 #endif
	void stopLoop();
	void initVr();

	int32_t m_isConvert;
public:
	int32_t initAudio(BPerPreProcess *pp);
	void startAudioCapture();
	BPerAudioBuffer* getOutAudioBuffer();
	void stopAudioCaptureState();
	void startAudioCaptureState();
	void setAec(BPerRtcAec *paec);
	void setInAudioBuffer(vector<BPerAudioPlayBuffer*> *pbuf);
};

#endif /* BPERAPP_BPERCAPTUREAPP_H_ */
